﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Accouting804.Utils
{
    public static class StringUtils
    {



    }

    public static class DateTimeUtils
    {
        public static string DateTimeString(this DateTime dt, OutputDateTimeString format = OutputDateTimeString.YYYYMMDDhhmmss)
        {
            switch (format)
            {
                case OutputDateTimeString.YYYYMMDDhhmmss:
                    return $"{dt.Year:d4}{dt.Month:d2}{dt.Day:d2}{dt.Hour:d2}{dt.Minute:d2}{dt.Second:d2}";
                case OutputDateTimeString.YYYYMMDD:
                    return $"{dt.Year:d4}{dt.Month:d2}{dt.Day:d2}";

                case OutputDateTimeString.YYYY_MM_DD_T_hh_mm_ss:
                    return $"{dt.Year:d4}-{dt.Month:d2}-{dt.Day:d2}T{dt.Hour:d2}:{dt.Minute:d2}:{dt.Second:d2}";
                case OutputDateTimeString.YYYY_MM_DD_sp_hh_mm_ss:
                    return $"{dt.Year:d4}-{dt.Month:d2}-{dt.Day:d2} {dt.Hour:d2}:{dt.Minute:d2}:{dt.Second:d2}";
                default:
                    return dt.DateTimeString(OutputDateTimeString.YYYYMMDDhhmmss);
            }
        }

    }
    public enum OutputDateTimeString
    {
        /// <summary>
        /// 19700102123456
        /// </summary>
        YYYYMMDDhhmmss,
        /// <summary>
        /// 19700103
        /// </summary>
        YYYYMMDD,
        /// <summary>
        /// 1970-10-04T18:36:46
        /// </summary>
        YYYY_MM_DD_T_hh_mm_ss,
        YYYY_MM_DD_sp_hh_mm_ss

    }

}
